//
//  MySQLParameter.h
//  LibMySQL
//
//  Created by Marcus Grenängen on 2009-08-04.
//  Copyright 2009 SneWs Soft. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <mysql.h>

/*
 * This class will represent a SQL parameter for usage in prepared
 * statements. 
 *
 * Usage: Create a sql statement like: INSERT INTO MyTable( Col1, Col2 ) VALUES( ?, ? );
 *		  The ? markers will be replaced with data from MySQLParameter in it's corresponding place.
 */
@interface MySQLParameter : NSObject {
	NSInteger dataType;
	id value;
	NSInteger length;
	BOOL isNull;
}

@property (nonatomic, readwrite) NSInteger dataType;
@property (nonatomic, readwrite, retain) id value;
@property (nonatomic, readwrite) NSInteger length;
@property (nonatomic, readwrite) BOOL isNull;


+ (MySQLParameter*)parameterWithValue:(id)v asType:(NSInteger)t;
+ (MySQLParameter*)parameterWithLong:(long)v;
+ (MySQLParameter*)parameterWithInt:(int)v;
+ (MySQLParameter*)parameterWithShort:(short)v;
+ (MySQLParameter*)parameterWithString:(NSString *)v;
+ (MySQLParameter*)parameterWithEnum:(char)v;

- (id)initWithValue:(id)v;
- (id)initWithValue:(id)v andType:(NSInteger)t;

- (NSString *)stringValue;

@end
